home *** CD-ROM | disk | FTP | other *** search
/ PC-SIG Library 8 / PC-SIG Library CD-ROM (8th Edition) (1990-04).iso / 001_100 / disk0004 / dump.bas (.txt) < prev    next >
Encoding:
GW-BASIC  |  1982-11-06  |  2.3 KB  |  72 lines

  1. 1  CLS:KEY OFF
  2. 10  REM------------------------------------------------------
  3. 20  REM
  4. 30  REM                     DUMP.BAS
  5. 40  REM      Print contents of the entire b-tree
  6. 50  REM
  7. 60  REM-------------------------------------------------------
  8. 70  GOTO 270
  9. 80  REM-----------------------------------------------------
  10. 90  REM
  11. 100  REM                 read.bas
  12. 110  REM    input a b-tree node from disk file #1
  13. 120  REM
  14. 130  REM-----------------------------------------------------
  15. 140  GET 1, P%:LSET REC$=R$
  16. 150  FOR INDEX%=1 TO N%
  17. 160    CH%=SIZE% *(INDEX%-1)
  18. 170    FLAG$=MID$(REC$,CH%+1,1)
  19. 180    IF FLAG$="E" THEN FLAG%(INDEX%)=0
  20. 190    IF FLAG$="F" THEN FLAG%(INDEX%)=1
  21. 200    IF FLAG$="D" THEN FLAG%(INDEX%)=2
  22. 210   KEYS$(INDEX%)=MID$(REC$,CH%+2,SIZE%-3)
  23. 220   ARC%(INDEX%)=CVI(MID$(REC$,CH%+SIZE%-1,2))
  24. 230  NEXT INDEX%
  25. 240  ARC%(N%+1)=CVI(MID$(REC$,126,2))
  26. 250  RETURN
  27. 260  REM
  28. 270  REM------------------------------------------------
  29. 280  REM
  30. 290  REM            QUICK READ-OUT OF B-TREE INDEX FILE
  31. 300  REM------------------------------------------------
  32. 310  FOR I%=1 TO  5:PRINT:NEXT I%
  33. 320  OPEN "I",2, "HEADER.DAT"
  34. 330    INPUT #2, FSCREEN$,ROOT%,LNG%,LNF%,AN%,LINS%,N%,SIZE%,INDEX$,MAST$
  35. 340  CLOSE 2
  36. 350  N0%=N%+1:DIM FLAG%(N0%),KEYS$(N0%),ARC%(N0%)
  37. 360  OPEN "R",1, INDEX$
  38. 370  FIELD 1,127 AS R$
  39. 380  REC$=SPACE$(128):LSET ZERO$="0"
  40. 390  K$=SPACE$(SIZE%-3)
  41. 400  INPUT"Turn on printer, Strike RETURN :" ;Y$
  42. 410  LPRINT"Quick dump of B-tree index file: "
  43. 420  LPRINT:LPRINT
  44. 430  P%=0
  45. 440  FOR I1%=1 TO LNF%
  46. 450    P%=P%+1:GOSUB 80          'read a node
  47. 460    LPRINT"------------------------------- Node = ",P%,"-----------------"
  48. 470    FOR I%=1 TO N%
  49. 480      IF FLAG%(I%)=0 THEN C$="Empty"
  50. 490      IF FLAG%(I%)=1 THEN C$="Full"
  51. 500      IF FLAG%(I%)=2 THEN C$="Deleted"
  52. 510      LPRINT "Flag =";C$;
  53. 520      LPRINT " Key =";KEYS$(I%);
  54. 530      LPRINT " Arc ="; ARC%(I%)
  55. 540    NEXT I%
  56. 550    LPRINT "Link = ";ARC%(N0%)
  57. 560  NEXT I1%
  58. 570  CLOSE 1
  59. 580  REM-----------------------other stuff-------------------------------
  60. 590  LPRINT:LPRINT
  61. 600  LPRINT"Root node =",ROOT%
  62. 610  LPRINT"Number items indexed =",LNG%
  63. 620  LPRINT"Number of nodes(sectors)= ",LNF%
  64. 630  LPRINT"Number of fields per input form = ",AN%
  65. 640  LPRINT"Number of lines per input form  = ",LINS%
  66. 650  LPRINT"Number of items per node(sector)= ",N%
  67. 660  LPRINT"Size(chars) of each node item   = ",SIZE%
  68. 670  LPRINT"Name of master(data) file       = ",MAST$
  69. 680  LPRINT"Name of index file (b-tree)     = ",INDEX$
  70. 690  RUN "dbmenu"
  71. 700  END
  72.